# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  # Get all controllers
  def all_controllers
    controllers = Dir.new("#{RAILS_ROOT}/app/controllers").entries
    cont_array = Array.new
    controllers.each { |controller|
      if controller =~ /_controller/
        cont = controller.gsub("_controller.rb", "")
        cont_array << cont
      end
    }
    cont_array.delete("application")
    
    return cont_array.sort!
  end

  # Find all positions
  def array_users
      User.all(:order => [:username.asc]).map {|g| [g.username, g.id]}
  end

  # Find all items by model
  def array_of(model)
      model.all(:order => [:title.asc]).map {|g| [g.title, g.id]}
  end
end
